/**
 * org.springframework.web.servlet.mvc.AbstractWizardFormController 可以讓您設計出如桌面應用程式的精靈（Wizard），通常用於問卷表單內容相當長時，<br>
 * 與其使用一個表單呈現所有的問卷內容，不如將問卷內容分作數個畫面，讓使用者一頁一頁完成問卷，您可以繼承AbstractWizardFormController，<br>
 * 並重新定義它的processFinish()方法，當中定義的是全部問卷提交完後的處。
 */

package controller.form.wizard;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractWizardFormController;

import com.e885.log.E885Logger;


/**
 * @author Eric.Kao(gau168.gau@msa.hinet.net)
 * @version 1.0
 * @company E885 Group
 * @copyright Copyright (c) 2001-2008
 */

public class MyAbstractWizardFormController extends AbstractWizardFormController
{
	private String finishPage;

	private String cancelPage;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.web.servlet.mvc.AbstractWizardFormController#processFinish(javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
	 */
	@Override
	protected ModelAndView processFinish( HttpServletRequest request, HttpServletResponse response, Object command, BindException errors )
		throws Exception
	{
		E885Logger.testLog.debug( "exeute method processFinish()" );

		AnswerCommand answerCommand = ( AnswerCommand )command;

		Map< String, String > map = new HashMap< String, String >();
		map.put( "answer1", answerCommand.getAnswer1() );
		map.put( "answer2", answerCommand.getAnswer2() );
		map.put( "answer3", answerCommand.getAnswer3() );

		return new ModelAndView( getFinishPage(), "answer", map );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.web.servlet.mvc.AbstractWizardFormController#processCancel(javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
	 */
	@Override
	protected ModelAndView processCancel( HttpServletRequest request, HttpServletResponse response, Object command, BindException errors )
		throws Exception
	{
		E885Logger.testLog.debug( "exeute method processCancel()" );

		return new ModelAndView( getCancelPage() );
	}

	/**
	 * @return the finishPage
	 */
	public String getFinishPage()
	{
		return finishPage;
	}

	/**
	 * @param finishPage the finishPage to set
	 */
	public void setFinishPage( String finishPage )
	{
		this.finishPage = finishPage;
	}

	/**
	 * @return the cancelPage
	 */
	public String getCancelPage()
	{
		return cancelPage;
	}

	/**
	 * @param cancelPage the cancelPage to set
	 */
	public void setCancelPage( String cancelPage )
	{
		this.cancelPage = cancelPage;
	}
}
